import Vue from 'vue'
import Vuex from 'vuex'
import user from './user'
import permission from './permission'


Vue.use(Vuex)

export default new Vuex.Store({
    modules: {
        permission,
        user
    },
    getters: {
        roles: state => state.user.roles,
        permission_routes: state => {
            // debugger
            state.permission.routes.forEach((ele, index) => {
                if (ele.children) {
                    state.permission.routes.splice(index, 1);
                    state.permission.routes.splice(index, ele.children.length, ...ele.children)
                }
            });
            console.log(state.permission.routes)
            return state.permission.routes
        },
        modulesName: state => state.user.modulesName
    }
})